<?php
/**
 ***** 扶摇而上、抱守本真 ******
 * @author Dana
 * @Date 2021/6/23
 */

include '../model/Mysql.php';
class User {

    public static function find($args)
    {
        $model = (new Mysql())::getInstance();
        $sql = "select name from user where $args[field] = $args[value]";
        var_dump($sql);
        return $model->query($sql);
    }

    public static function __callStatic($method,$args)
    {
        if(preg_match('/^findBy(.+)$/',$method,$matches)){
            return static::find(['field'=>$matches[1],'value'=>$args[0]]);
        }
    }

}

$user = User::findById(1);
var_dump($user);



